import  express  from 'express';
import path from "path"
import cookieParser from 'cookie-parser';
import logger from "morgan"
import cors from "cors"

//引入

import LiRouter from "./routes/LiAoYang"

import verifyTokenMiddle from './middleware/verifyTokenMiddle';
import errorTokenMiddleware from "./middleware/errorTokenMiddleware"

const app = express();
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(cors()) //解决跨域

//在匹配路由之前验证token
app.use(verifyTokenMiddle())
//提示返回的错误
app.use(errorTokenMiddleware())


//使用
app.use("/Li",LiRouter)



module.exports = app;
